package com.hbase.mr2;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

public class Example2Driver {

	public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {

		// 创建一个job的configuration
		Configuration conf = HBaseConfiguration.create();

		// 创建job
		Job job = Job.getInstance(conf);

		job.setJobName("example2");

		job.setJarByClass(Example2Driver.class);

		// 配置job

		// 配置job的Mapper设置
		job.setMapperClass(Example2Mapper.class);
		job.setMapOutputKeyClass(Text.class);
		job.setMapOutputValueClass(Put.class);
		// 设置输入目录
		FileInputFormat.setInputPaths(job, new Path("hdfs://hadoop02:9000/user/hive/warehouse/test.db/person_info2/person_info2.txt"));

		// 配置job的Reducer设置
		TableMapReduceUtil.initTableReducerJob("t5", Example2Reducer.class, job);


		// 运行
		job.waitForCompletion(true);

	}

}
